package ywpt.service.people;

import java.util.List;

import org.hibernate.criterion.DetachedCriteria;
import org.springframework.stereotype.Service;

import ywpt.core.dao.HibernateEntityDao;
import ywpt.model.PeopleExperience;
import ywpt.model.PeopleInfo;
@Service("experienceService")
public class ExperienceServiceImpl extends HibernateEntityDao<PeopleExperience> implements ExperienceService{

	public ExperienceServiceImpl(){
		
	}
	@Override
	public PeopleExperience getExperienceInfoById(Long id) {
		return this.get(id);
	}

	@Override
	public int getExperienceInfoCountByCriteria(DetachedCriteria query) {
		return this.getCountByCriteria(query);
	}

	@SuppressWarnings("unchecked")
	@Override
	public List<PeopleExperience> getExperienceInfos(DetachedCriteria query,
			int pageSize, int startIndex) {
		return this.findAllByCriteria(query, pageSize, startIndex);
	}

	@Override
	public void removeExperienceInfo(Long id) {
		this.removeById(id);
	}

	@Override
	public void saveExperienceInfo(PeopleExperience experienceInfo,Long peopleId) {
		if(peopleId != null){
			experienceInfo.setPeople(this.get(PeopleInfo.class, peopleId));
		}
		this.save(experienceInfo);
	}

	@Override
	public void updateExperienceInfo(PeopleExperience experienceInfo,Long peopleId) {
		if(peopleId != null){
			experienceInfo.setPeople(this.get(PeopleInfo.class, peopleId));
		}
		this.update(experienceInfo);
	}

}
